package io.renren.modules.mail.controller;

/*import com.mail.pojo.Paper;
import com.mail.service.DeleteService;
import com.mail.service.InsertService;
import com.mail.service.PageService;
import com.mail.vo.JsonResult;
import com.mail.vo.PageObject;*/

import io.renren.modules.mail.pojo.Paper;
import io.renren.modules.mail.service.DeleteService;
import io.renren.modules.mail.service.InsertService;
import io.renren.modules.mail.service.PageService;
import io.renren.modules.mail.vo.JsonResult;
import io.renren.modules.mail.vo.PageObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/")
//进入邮箱初始界面
public class PageController {
    @Autowired(required = false)
    PageService pageService;
    InsertService insertService;
    DeleteService deleteService;
    //程序入口
    @RequestMapping("login")
    public String logIn() {
        return "starter";
    }

    @RequestMapping("selectall")
    public String selectAll(){
        return null;
    }

    @RequestMapping("insertFileInDatabase")
    public String insertFileInDatabase(){
        insertService.insert();
        return "redirect:/success";
    }
    @RequestMapping("returnLogin")
    public String returnLogin(){
        return "redirect:login";
    }


    @RequestMapping("doFindPageObjects")
    @ResponseBody
    public JsonResult doFindPageObjects(Integer pageCurrent) throws Exception {
        PageObject<Paper> pageObject = pageService.findPageObjects(pageCurrent);
        return new JsonResult(pageObject);
    }
    @RequestMapping("deletePaperById")
    public String deletePaperById(Integer id){
        deleteService.deletePageById(id);
        return "redirect:/success";
    }
    @RequestMapping("log")
    public String doPageUI(){
        return "log";
    }
}
